<template>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px">
        <h4>涂鸦展后台界面</h4>
        <el-menu>
          <el-menu-item index="1"
            @click="router.push('/homes/users'); breadcrumbData.firstLevelColumn = '用户管理';">用户管理</el-menu-item>
          <el-menu-item index="2"
            @click="router.push('/homes/exList'); breadcrumbData.firstLevelColumn = '展览管理';">展览管理</el-menu-item>
          <el-menu-item index="3"
            @click="router.push('/homes/shen'); breadcrumbData.firstLevelColumn = '内容审核';">内容审核</el-menu-item>
          <el-menu-item index="4"
            @click="router.push('/homes/goods'); breadcrumbData.firstLevelColumn = '商品管理'">商品管理</el-menu-item>
          <el-menu-item index="5"
            @click="router.push('/homes/order'); breadcrumbData.firstLevelColumn = '订单管理';">订单管理</el-menu-item>
        </el-menu>
      </el-aside>
      <el-container>
        <el-header>
          <span>欢迎您:{{ username }}</span>
          <a href @click.prevent="logout">退出登录</a>
        </el-header>
        <el-main>
          <el-card shadow="never">
            <el-breadcrumb separator="/">
              <!-- 面包屑导航 -->
              <el-breadcrumb-item :to="{ path: '/homes/index' }">首页</el-breadcrumb-item>
              <el-breadcrumb-item v-if="route.path!='/homes' && breadcrumbData.firstLevelColumn != ''">{{ breadcrumbData.firstLevelColumn }}</el-breadcrumb-item>
              <el-breadcrumb-item v-if="route.path!='/homes' && breadcrumbData.secondLevelColumn != ''"> {{ breadcrumbData.secondLevelColumn }}</el-breadcrumb-item>
            </el-breadcrumb>
          </el-card>
          <el-card shadow="never" class="main-content">
            <router-view v-if="route.path != '/homes'"></router-view>
            <div v-else>
              
            </div>
          </el-card>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>


<script setup>
/* 管理员退出登录 */
const username = window.localStorage.getItem('username');
const logout = () => {
  window.localStorage.removeItem('username');
  router.push('/login')
}
/* 侧边栏 */

/* 路由管理 */
import { useRouter, useRoute } from "vue-router";
const router = useRouter();
const route = useRoute();
/* 面包屑 */
import { ref } from "vue";
const breadcrumbData = ref({
  firstLevelColumn: '',
  secondLevelColumn: ''
})
</script>

<style scoped>
.el-container {
  height: 100vh;
}

.el-aside {
  background: #2f63b8;
  color: white;
}

.el-aside>h4 {
  text-align: center;
}

.el-header {
  border-bottom: 2px solid #ededed;
}

.el-main {
  background: #f9f9f9;
}

.el-header {
  border-bottom: 2px solid #ededed;
  display: flex;
  align-items: center;
  justify-content: end;
}

.el-header>span {
  margin-right: 15px;
}

.main-content {
  margin-top: 20px;
  min-height: 360px;
}


.el-menu-item span {
  margin-left: 12px;
}
</style>

